package njust.csc.aecore

import njust.csc.aecore.analysis.StaticExplorer
import njust.csc.aecore.utils.PathUtils
import kotlin.io.path.listDirectoryEntries

/**
 * @Author ZhouHang
 * @Date 24/5/29 周三
 * 静态分析脚本，支持批量分析，得到 apk 基础信息
 * */

fun main() {
    val relativeDir = "scam_static_fail/东方机构.apk"
    val explorer = StaticExplorer(relativeDir)
//    explorer.dump(PathUtils.getBaseInfoPath(relativeDir), append = true)
//    batchStaticExplore("gamble")
}

/**
 * 批量分析 apk
 * @param relativeDir 相对于 INPUT 的路径，分析该路径下的所有 apk
 * */
fun batchStaticExplore(relativeDir: String) {
    for (apk in PathUtils.INPUT.resolve(relativeDir).listDirectoryEntries()) {
        val relativePath = PathUtils.INPUT.relativize(apk).toString()
        val explorer = StaticExplorer(relativePath)
        explorer.dump(PathUtils.getBaseInfoPath(relativePath), append = true)
    }
}
